package com.xr.pfm;

import java.util.ArrayList;
import java.util.List;

import com.bstek.dorado.common.*;
import com.bstek.dorado.data.*;
import com.bstek.dorado.data.db.DBStatement;
import com.bstek.dorado.utils.variant.VariantSet;
import com.bstek.dorado.view.*;
import com.bstek.dorado.view.data.*;
import com.bstek.dorado.view.control.*;

/**
 * formulaViewModel
 */
public class formulaViewModel extends DefaultViewModel {
  

  protected void doUpdateData(ParameterSet parameters, ParameterSet outParameters)
      throws Exception {
	  DBStatement dbs=new DBStatement();
	  
     Dataset ds =getDataset("datasetFormula");
     String tableName=parameters.getString("TABLE_NAME");
     String formulaShow=ds.getString("display");
	  String testStr=formulaShow,retStr=formulaShow;
	  if (testStr==null ||testStr.equals("")){
		  outParameters.setString("formula", retStr);
		  return;
	  }
     dbs.setSql("select * from PFM_FIELDS_MAPPING where upper(TABLE_NAME)= upper('"+tableName+"')");
     List list=dbs.queryForList();
     for (int i=0;i < list.size();i++){
    	 VariantSet vs=(VariantSet) list.get(i);
    	 testStr=testStr.replace("["+vs.getString("FIELD_NAME_CN").trim()+"]", "100");
    	 retStr=retStr.replace("["+vs.getString("FIELD_NAME_CN").trim()+"]", "["+vs.getString("FIELD_NAME_EN")+"]");
     }
     dbs.setSql("select "+testStr+" from dual");
     dbs.execute();
	  outParameters.setString("formula", retStr);
	  
   // super.doUpdateData(parameters, outParameters);
  }

  private List getItems(String str){
	  List list=new ArrayList();
	  //str.
	  return list;
  }
  
}
